<extend name="./Application/Admin/View/common/base.html" />
<block name="crumb">
    <span class="c-gray en">&gt;</span> 退换货管理
    <span class="c-gray en">&gt;</span> 退货申请信息
</block>
<block name="content">
    <div class="panel panel-default">
        <input name="iid" type="hidden" value="{$id}">
        <div class="panel-header">申请信息</div>
        <div class="panel-body">
            <p><span>订单编号:</span> {$returnGood['order']['order_id']}</p>
            <p><span>申请退款金额:</span> <strong>{$returnGood['price']}</strong>元</p>
            <p><span>用户:</span> {$returnGood['agent_name']}</p>
            <p><span>申请日期:</span> {$returnGood['now_time']|date="Y-m-d H:i:s",###}</p>
            <p><span>商品名称</span></p>
            <volist name="orderGood" id="good"><p style="margin-left: 80px;"><a href="">{$good['g_name']}</a></p></volist>
            <p><span>售后申请描述：</span>{$returnGood['reason']}</p>
            <p><span>退货申请上传照片</span></p>
            <p style="margin-left: 50px;"><volist name="returnGood['images']" id="vo"><img src="__ROOT__/Uploads/{$vo.url}" style="width: 125px;height: 85px;"></volist></p>
            <p>
                审核意见:
                <if condition="$returnGood['state'] eq 0">
                    <input type="radio" name="state" value="1" checked>审核通过  <input type="radio" name="state" value="-1">拒绝通过
                    <elseif condition="$returnGood['state'] eq 1"/>
                    <span class="label label-success radius">已通过</span>
                    <else/>
                    <span class="label label-danger radius">不通过</span>
                </if>
            </p>
            <if condition="$returnGood['state'] eq 0"><p id="return">退款金额: <input type="text" name="return_price" class="input-text radius size-S" style="width: 200px;"></p></if>
            <if condition="$returnGood['state'] eq 0">
                <p>
                    <textarea id="info" class="textarea" placeholder="请填写处理描述！"></textarea>
                </p>
                <p><button id="save" class="btn btn-secondary radius" type="submit"><i class="Hui-iconfont"></i> 保存</button></p>
            </if>


            <if condition="$returnGood['state'] neq 0">
                    <span style="float: left;margin-left: 20px;">处理描述：</span><textarea class="textarea" disabled style="width: 80%;">{$returnGood['info']}</textarea>
            </if>



        </div>
    </div>
</block>
<block name="css">
    <style>.panel-body p {margin-left: 20px;}span{color:#999;}</style>
</block>
<block name="js">
    <script type="text/javascript">
        $(function () {

            //切换到拒绝通过的时候，隐藏金额输入
            var flag = false;
            $('input[name="state"]').click(function () {
                if($(this).val() != 1) {
                    $('#return').hide();
                } else {
                    flag = true;
                    $('#return').show();
                }
            });

            //提交审核
            $('#save').click(function () {
                var info = $('#info').val();
                var return_price = $('input[name="return_price"]').val();

                if (return_price == '' && flag) {
                    layer.msg('请填写退款金额！', {icon: 8,time:1000});
                    return false;
                }


                if (info == '') {
                    layer.msg('请填写处理描述！', {icon: 8,time:1000});
                    return false;
                }



                $.ajax({
                    url:"{:U('ReturnGood/make')}",
                    type:'post',
                    data: {
                        'state': $('input[name="state"]:checked').val(),
                        'info': $('#info').val(),
                        'id': $('input[name="iid"]').val(),
                        'return_price': return_price
                    },
                    beforeSend: function () {
                        layer.msg('操作中..', {icon: 16,time:500});
                    },
                    success: function (msg) {
                        window.location.href = "{:U('returnGood/index')}"
                    }
                });

            });
        });
    </script>
</block>
